<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>询价测试</title>
    <script type="text/javascript"
            src="http://static.bgext.com/dropdown-data.js"></script>
    <jsp:include page="../../head.jsp"/>
    <style type="text/css">
        .ui-autocomplete{
            max-height: 200px;
            overflow-y: auto;
        }
    </style>
    <script type="text/javascript">
        var iePortData = [];
        for (var i = 0; i < DROPDOWN_DATA.export_port.length; i++) {
            var expPort = DROPDOWN_DATA.export_port[i];
            var arr = [];
            arr.push(expPort.name);
            arr.push(expPort.code);
            iePortData.push(arr);
        }

        var formSetting = {
            title: "询价测试",
            module: 'query',
            columns: [
                {
                    name: "feeType",
                    label: "报价/成本",
                    type: "dropdown",
                    data: [["报价", "0"], ["成本", "1"]],
                    value: "0",
                    validate: 'validate[required]'
                }, {
                    name: "isCCI",
                    label: "通关一体化",
                    type: "dropdown",
                    data: [["通关一体化", "1"], ["一般申报", "0"]],
                    value: "0",
                    validate: 'validate[required]'
                }, {
                    name: "ieType",
                    label: "进出口",
                    type: "dropdown",
                    data: [["进口", "I"], ["出口", "E"]],
                    value: "E",
                    validate: 'validate[required]'
                }, {
                    name: "supComId",
                    label: "申报报关行",
                    type: "dropdown",
                    dropdownType: "ajax",
                    url: "<s:url value='/order-dropdown/supCompany'/>",
                    op: "eq",
                    minLength: 0,
                    keyWordName: "key",
                    success: function (data) {
                        data = data.results;
                        var array = new Array();
                        $.each(data, function (i, n) {
                            array.push([n["name"], n["value"]]);
                        });
                        return array;
                    },
                    validate: 'validate[required]'
                }, {
                    name: "iePortCode",
                    label: "进/出口口岸",
                    type: "dropdown",
                    data: iePortData,
                    value:"5189",
                    minLength: 0,
                    validate: 'validate[required]'
                }, {
                    name: "transitType",
                    label: "直转类型",
                    type: "dropdown",
                    data: [["直航", "ZH"], ["转关", "ZG"]],
                    value:"ZH",
                    minLength: 0,
                    validate: 'validate[required]'
                }, {
                    name: "goodsCount",
                    label: "商品项数",
                    value:"0",
                    validate: 'validate[required]'
                }, {
                    name: "contaCount",
                    label: "集装箱数",
                    value:"0",
                    validate: 'validate[required]'
                }],
            buttons: {
                custom: []
            },
            grid: {
                id: "tGrid",
                title: "查询结果",
                url: "<s:url value="/fund/charging/test-query"/>",
                colModel: [{
                    name: "name",
                    label: "名称",
                    align: 'center'
                }, {
                    name: "descript",
                    label: "描述",
                    align: 'center'
                }, {
                    name: "count",
                    label: "数量",
                    align: 'center'
                }, {
                    name: "unitPrice",
                    label: "单价",
                    align: 'center'
                },{
                    name: "totalPrice",
                    label: "总价",
                    align: 'center',
                    formatter:"number",
                    summaryType:'sum'
                }],
                footerrow : true,
                userDataOnFooter : true,
                loadComplete:function(){
                    var totalPrice = $("#tGrid").getCol('totalPrice', false, 'sum');
                    totalPrice = totalPrice < 0 ? 0.0 : totalPrice;
                    var count = $("#tGrid").getCol('count', false, 'sum');
                    count = count < 0 ? 0.0 : count;
                    $("#tGrid").footerData('set', {'totalPrice':totalPrice, 'count':count}, true);
                }
            }
        };
        $(document).ready(function () {
            $("#table").mrdForm(formSetting);
            $("body input").on("keydown", function(event){
                if(event.keyCode === 13){
                    $("#queryButton").click();
                }
            });
        });
    </script>
</head>
<body>
<div id="table"></div>
</body>
</html>
